package view;

import javax.swing.ImageIcon;
import javax.swing.JFrame;
import javax.swing.JLabel;

public class MenuPanel extends javax.swing.JPanel
{

    private static JLabel contentBackground;
    private JFrame window;
    private int flag = 0;
    private HireRoomPanel hrPanel;
    private RoomCategoryPanel rcPanel;
    private StatPanel sPanel;
    private CheckOutPanel coPanel;
    private CustomerCategoryPanel ccPanel;
    private RootPanel rPanel;
    private AboutPanel aPanel;
    private AboutPanel aPanel1;

    public MenuPanel(JFrame window)
    {
        initComponents();
        this.window = window;
        rPanel = new RootPanel();
        rcPanel = new RoomCategoryPanel(window);
        hrPanel = new HireRoomPanel(window);
        sPanel = new StatPanel(window);
        coPanel = new CheckOutPanel(window);
        ccPanel = new CustomerCategoryPanel(window);
        aPanel = new AboutPanel(window);
        aPanel1 = new AboutPanel(window);
        aPanel1.Show();
    }

    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents()
    {

        btn_room = new javax.swing.JLabel();
        btn_customer = new javax.swing.JLabel();
        btn_rent = new javax.swing.JLabel();
        btn_pay = new javax.swing.JLabel();
        btn_stat = new javax.swing.JLabel();
        btn_about = new javax.swing.JLabel();

        btn_room.setIcon(new javax.swing.ImageIcon(getClass().getResource("/data/room.png"))); // NOI18N
        btn_room.setAlignmentY(0.0F);
        btn_room.addMouseListener(new java.awt.event.MouseAdapter()
        {
            public void mousePressed(java.awt.event.MouseEvent evt)
            {
                btn_roomMousePressed(evt);
            }
        });

        btn_customer.setIcon(new javax.swing.ImageIcon(getClass().getResource("/data/customer.png"))); // NOI18N
        btn_customer.setAlignmentY(0.0F);
        btn_customer.addMouseListener(new java.awt.event.MouseAdapter()
        {
            public void mousePressed(java.awt.event.MouseEvent evt)
            {
                btn_customerMousePressed(evt);
            }
        });

        btn_rent.setIcon(new javax.swing.ImageIcon(getClass().getResource("/data/rent.png"))); // NOI18N
        btn_rent.addMouseListener(new java.awt.event.MouseAdapter()
        {
            public void mousePressed(java.awt.event.MouseEvent evt)
            {
                btn_rentMousePressed(evt);
            }
        });

        btn_pay.setIcon(new javax.swing.ImageIcon(getClass().getResource("/data/pay.png"))); // NOI18N
        btn_pay.addMouseListener(new java.awt.event.MouseAdapter()
        {
            public void mousePressed(java.awt.event.MouseEvent evt)
            {
                btn_payMousePressed(evt);
            }
        });

        btn_stat.setIcon(new javax.swing.ImageIcon(getClass().getResource("/data/stat.png"))); // NOI18N
        btn_stat.addMouseListener(new java.awt.event.MouseAdapter()
        {
            public void mousePressed(java.awt.event.MouseEvent evt)
            {
                btn_statMousePressed(evt);
            }
        });

        btn_about.setIcon(new javax.swing.ImageIcon(getClass().getResource("/data/about.png"))); // NOI18N
        btn_about.addMouseListener(new java.awt.event.MouseAdapter()
        {
            public void mousePressed(java.awt.event.MouseEvent evt)
            {
                btn_aboutMousePressed(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(btn_about)
                    .addComponent(btn_stat)
                    .addComponent(btn_pay)
                    .addComponent(btn_rent)
                    .addComponent(btn_customer)
                    .addComponent(btn_room)))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(btn_room)
                .addGap(0, 0, 0)
                .addComponent(btn_customer)
                .addGap(0, 0, 0)
                .addComponent(btn_rent)
                .addGap(0, 0, 0)
                .addComponent(btn_pay, javax.swing.GroupLayout.PREFERRED_SIZE, 62, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(0, 0, 0)
                .addComponent(btn_stat)
                .addGap(0, 0, 0)
                .addComponent(btn_about))
        );
    }// </editor-fold>//GEN-END:initComponents

    private void btn_roomMousePressed(java.awt.event.MouseEvent evt)//GEN-FIRST:event_btn_roomMousePressed
    {//GEN-HEADEREND:event_btn_roomMousePressed

        ResetLayout();
        flag = 1;
        rcPanel.Show();
        btn_room.setIcon(new javax.swing.ImageIcon(getClass().getResource("/data/room_click.png")));
    }//GEN-LAST:event_btn_roomMousePressed

    private void btn_customerMousePressed(java.awt.event.MouseEvent evt)//GEN-FIRST:event_btn_customerMousePressed
    {//GEN-HEADEREND:event_btn_customerMousePressed
        ResetLayout();
        flag = 2;
        ccPanel.Show();
        btn_customer.setIcon(new javax.swing.ImageIcon(getClass().getResource("/data/customer_click.png"))); // NOI18N
    }//GEN-LAST:event_btn_customerMousePressed

    private void btn_rentMousePressed(java.awt.event.MouseEvent evt)//GEN-FIRST:event_btn_rentMousePressed
    {//GEN-HEADEREND:event_btn_rentMousePressed
        ResetLayout();
        flag = 3;
        hrPanel.Show();
        btn_rent.setIcon(new javax.swing.ImageIcon(getClass().getResource("/data/rent_click.png"))); // NOI18N
    }//GEN-LAST:event_btn_rentMousePressed

    private void btn_payMousePressed(java.awt.event.MouseEvent evt)//GEN-FIRST:event_btn_payMousePressed
    {//GEN-HEADEREND:event_btn_payMousePressed
        ResetLayout();
        flag = 4;
        coPanel.Show();
        btn_pay.setIcon(new javax.swing.ImageIcon(getClass().getResource("/data/pay_click.png")));
    }//GEN-LAST:event_btn_payMousePressed

    private void btn_statMousePressed(java.awt.event.MouseEvent evt)//GEN-FIRST:event_btn_statMousePressed
    {//GEN-HEADEREND:event_btn_statMousePressed
        ResetLayout();
        flag = 5;
        sPanel.Show();
        btn_stat.setIcon(new javax.swing.ImageIcon(getClass().getResource("/data/stat_click.png")));
    }//GEN-LAST:event_btn_statMousePressed

    private void btn_aboutMousePressed(java.awt.event.MouseEvent evt)//GEN-FIRST:event_btn_aboutMousePressed
    {//GEN-HEADEREND:event_btn_aboutMousePressed
        ResetLayout();
        flag = 6;
        aPanel.Show();
        btn_about.setIcon(new javax.swing.ImageIcon(getClass().getResource("/data/about_click.png")));

    }//GEN-LAST:event_btn_aboutMousePressed
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JLabel btn_about;
    private javax.swing.JLabel btn_customer;
    private javax.swing.JLabel btn_pay;
    private javax.swing.JLabel btn_rent;
    private javax.swing.JLabel btn_room;
    private javax.swing.JLabel btn_stat;
    // End of variables declaration//GEN-END:variables

    public void Show()
    {
        btn_room.setIcon(new javax.swing.ImageIcon(getClass().getResource("/data/room.png")));
        btn_customer.setIcon(new javax.swing.ImageIcon(getClass().getResource("/data/customer.png")));
        btn_rent.setIcon(new javax.swing.ImageIcon(getClass().getResource("/data/rent.png")));
        btn_pay.setIcon(new javax.swing.ImageIcon(getClass().getResource("/data/pay.png")));
        btn_stat.setIcon(new javax.swing.ImageIcon(getClass().getResource("/data/stat.png")));
        btn_about.setIcon(new javax.swing.ImageIcon(getClass().getResource("/data/about.png")));
        this.setBounds(0, 69, 184, 372);
        this.setVisible(true);
        window.add(this);
    }

    public void Hide()
    {
        this.setVisible(false);
        aPanel1.setVisible(false);
    }

    private void ResetLayout()
    {
        Hide();

        Show();
//                     ImageIcon ic2 = new ImageIcon(MainFrame.class.getResource("/data/background.png"));
//        contentBackground = new JLabel(ic2);
//        contentBackground.setBounds(0, 0, 795, 550);
//        window.add(contentBackground);
        switch (flag)
        {
            case 1:
                rcPanel.setVisible(false);
                break;
            case 2:
                ccPanel.setVisible(false);
                break;
            case 3:
                hrPanel.setVisible(false);
                break;
            case 4:
                coPanel.setVisible(false);
                break;
            case 5:
                sPanel.setVisible(false);
                break;
            case 6:
                aPanel.setVisible(false);
                break;
            default:
                break;
        }
    }
}
